# -*- coding:utf-8 -*-

class Solution(object):
    def convert(self, s, numRows):
        """
        :type s: str
        :type numRows: int
        :rtype: str
        """
        if len(s) <= numRows or numRows<2 :
            return s
        res = []
        length = len(s)

        for i in xrange(numRows):
            for j in xrange(i,length,2*numRows-2):
                res.append(s[j])
                if i != 0 and i != numRows-1:
                    mid = j+(numRows-i-1)*2
                    if mid < length:
                        res.append(s[mid])

        return "".join(res)

if __name__ == "__main__":
    print Solution().convert("abc",2)